package com.bobby.dao.impl;

import com.bobby.dao.BaseDao;
import com.bobby.dao.OrderDao;
import com.bobby.dao.OrderItemDao;
import com.bobby.pojo.OrderItem;

import java.sql.SQLException;
import java.util.List;

/**
 * @Description TODO
 * @Date 2020/8/16 15:20
 * @Created wenjunpei
 */
public class OrderItemDaoImp extends BaseDao<OrderItem> implements OrderItemDao {
    @Override
    public void saveOrderItem(OrderItem orderItem) throws SQLException {
        String sql = "insert into t_order_item(name,count,price,total_price,order_id) values(?,?,?,?,?)";
        update(sql,orderItem.getName(),orderItem.getCount(),orderItem.getPrice(),orderItem.getTotalPrice(),orderItem.getOrderId());
    }

    @Override
    public List<OrderItem> queryOrderItemByOrderId(String orderId) throws SQLException {
        String  sql = "select id , name , count, price,total_price totalPrice , order_id  orderId  from t_order_item where order_id = ?";
        return queryForList(sql,orderId);
    }
}
